package com.ruoyi.information.controller.back;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.information.domain.back.CooperateBack;
import com.ruoyi.information.service.back.ICooperateBackService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商务合作Controller
 *
 * @author ruoyi
 * @date 2023-07-14
 */
@RestController
@RequestMapping("/cooperateBack")
public class CooperateBackController extends BaseController
{
    @Autowired
    private ICooperateBackService cooperateBackService;

    /**
     * 查询商务合作列表
     */
    @RequiresPermissions("information:cooperateBack:list")
    @GetMapping("/list")
    public TableDataInfo list(CooperateBack cooperateBack)
    {
        startPage();
        List<CooperateBack> list = cooperateBackService.selectCooperateBackList(cooperateBack);
        return getDataTable(list);
    }

    /**
     * 导出商务合作列表
     */
    @RequiresPermissions("information:cooperateBack:export")
    @Log(title = "商务合作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CooperateBack cooperateBack)
    {
        List<CooperateBack> list = cooperateBackService.selectCooperateBackList(cooperateBack);
        ExcelUtil<CooperateBack> util = new ExcelUtil<CooperateBack>(CooperateBack.class);
        util.exportExcel(response, list, "商务合作数据");
    }

    /**
     * 获取商务合作详细信息
     */
    @RequiresPermissions("information:cooperateBack:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cooperateBackService.selectCooperateBackById(id));
    }

    /**
     * 新增商务合作
     */
    @RequiresPermissions("information:cooperateBack:add")
    @Log(title = "商务合作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CooperateBack cooperateBack)
    {
        return toAjax(cooperateBackService.insertCooperateBack(cooperateBack));
    }

    /**
     * 修改商务合作
     */
    @RequiresPermissions("information:cooperateBack:edit")
    @Log(title = "商务合作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CooperateBack cooperateBack)
    {
        cooperateBack.setIsNew(0L);
        cooperateBack.setIsNewo(1);
        return toAjax(cooperateBackService.updateCooperateBack(cooperateBack));
    }

    /**
     * 删除商务合作
     */
    @RequiresPermissions("information:cooperateBack:remove")
    @Log(title = "商务合作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cooperateBackService.deleteCooperateBackByIds(ids));
    }
}
